package com.youyoulong.framework.util.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class PublicHandlerInterceptor extends HandlerInterceptorAdapter
{
    private final Logger log = Logger.getLogger(PublicHandlerInterceptor.class);
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception
    {

        String requestUri = request.getRequestURI();
        String contextPath = request.getContextPath();
        String url = requestUri.substring(contextPath.length());
        
        log.info("requestUri:" + requestUri);
        log.info("contextPath:" + contextPath);
        log.info("url:" + url);
        
//        String username = (String)request.getSession().getAttribute("user");
//        if (username == null)
//        {
//            request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
//            return false;
//        }
//        else
            return true;
    }
}
